﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Web_Oto.Bases;
using Web_Oto.Data;
using Web_Oto.Data.Dto;

namespace Web_Oto.Business
{
    public class NewsBus : busObject
    {
        #region Constructor

        public NewsBus()
        {
            m_objDAL = new NewsDal(connectionstring, connectiontype);
        }

        public NewsBus(string connectionString)
            : base(connectionString)
        {
            m_objDAL = new NewsDal(connectionstring, connectiontype);
        }

        public NewsBus(string connectionString, string connectionType)
            : base(connectionString, connectionType)
        {
            m_objDAL = new NewsDal(connectionstring, connectiontype);
        }

        private NewsDal m_objDAL;

        #endregion

        #region methods

        public IList<New> GetAllNews(string name = "", string intro = "")
        {
            return m_objDAL.GetAllNews(name, intro);
        }

        public IList<New> GetAllNews(int? currentPage, int itemPerPage, out int totalRecord)
        {
            return m_objDAL.GetAllNews(currentPage, itemPerPage, out totalRecord);
        }

        public IList<New> GetTopNews(int showItem, bool? showHomePage)
        {
            return m_objDAL.GetTopNews(showItem, showHomePage);
        }

        public IList<New> GetAnotherNews(int newsId)
        {
            return m_objDAL.GetAnotherNews(newsId);
        }

        public New GetNewsById(int id)
        {
            return m_objDAL.GetNewsById(id);
        }

        public int Delete(int id)
        {
            return m_objDAL.Delete(id);
        }

        public int Update(New nNew)
        {
            return m_objDAL.Update(nNew);
        }

        public int Insert(New nNew)
        {
            return m_objDAL.Insert(nNew);
        }

        public string GetFilePathById(int id)
        {
            return m_objDAL.GetFilePathById(id);
        }

        #endregion
    }
}
